﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.CMS263.BLL;
using Com.CMS263.PO;
using Com.CMS263.Util;
using System.Text;


namespace Com.CMS263.Web.manage
{
    public partial class control : System.Web.UI.Page
    {
        public int roleId = 0;
        public ArtTypeBLL atbll = new ArtTypeBLL();
        public IList<ArtType> atlist = new List<ArtType>();
        public string powers = "";
        AdminRoleBLL arbll = new AdminRoleBLL();

        protected void Page_Load(object sender, EventArgs e)
        {
            atlist = atbll.GetArtTypeByPid(0);

            roleId = Convert.ToInt32(Request.QueryString.Get("rid"));
            if (roleId > 0)
            {
                AdminRole ar = new AdminRole();
                ar = arbll.GetAdminUserByID(roleId);
                if (ar.rolePower.Length > 1)
                {
                    powers = SelectedPower(ar.rolePower);
                }
            }
            else
            {
                StringUtil.Alert("抱歉,不可操作", "-1");
            }
        }
        public string SelectedPower(string str)
        {
            str = str.Substring(0, str.Length - 1);
            //string[] strs = str.Split(',');
            return str;


        }
        StringBuilder sb = new StringBuilder();
        public string GetControlTree(int pid)
        {
            IList<ArtType> atype = new List<ArtType>();
            atype = atbll.GetArtTypeByPid(pid);
            if (atype != null && atype.Count > 0)
            {
                sb.Append("<UL >");

                foreach (ArtType att in atype)
                {
                    sb.Append("<LI><input id='chk" + att.id + "' type='checkbox' onclick='addcontrol(" + att.id + ",this)' value=" + att.id + " name='chk'  pid='" + att.pid + "' />" + att.typeName);
                    sb.Append("");

                    sb.Append("</LI>");
                    GetControlTree(att.id);
                }
                sb.Append("</UL>");
            }

            return sb.ToString();

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string menuids = Request["chk"];
            StringUtil.Alert(menuids, "-1");
        }
    }
}
